package com.example.securitytest.api;

import com.example.securitytest.dao.BombDAO;
import com.example.securitytest.dataobject.Bomb;
import com.example.securitytest.model.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/bomb")
public class BombAPI {

	@Autowired
	private BombDAO bombDAO;

	@GetMapping("/get")
	public Result<List<Bomb>> getAll() {
		List<Bomb> bombs = bombDAO.getAll();
		Result<List<Bomb>> result = new Result<>();
		result.setResultSuccess("查询成功！", bombs);
		return result;
	}

	@PostMapping("/add")
	public Result<Bomb> add(@RequestBody Bomb bomb) {
		bombDAO.add(bomb);
		Result<Bomb> result = new Result<>();
		result.setResultSuccess("添加成功！", bomb);
		return result;
	}

}